<?php
$dir = dirname(__DIR__,2);
require($dir.'/vendor/autoload.php');
if (substr($_SERVER['REQUEST_URI'],0,6)=='/user/'){
$env = json_decode(file_get_contents($dir.'/.env/env.json'), true);
$lia = new \Lia(); // a framework named Liaison
$main = \Lia\Package\Server::main($lia); // a built-in package & set of addons
// this file will be deleted automatically, unless an error occurs
$initialization_pin_file = __DIR__.'/user-initialization-pin.txt';
$config_file = __DIR__.'/user-config.json';
$userLib = new \Tlf\User\EasyServer($lia, $initialization_pin_file, $config_file, $env);
// If you want the library to handle head,body, etc, then uncomment the next two lines & delete the rest. It's not styled.
//$userLib->enableFullPage();
//$userLib->deliver(); #
$response = $lia->getResponse();
if (count($response->headers) > 0){
$response->sendHeaders(); // redirects, maybe errors idr
exit;
} else {
// You might instead print the content inside your page layout.
echo $response->content;
exit;
}
}
// custom routing, though you may want to remove query string or use a framework or a minimal routing library and view library.
switch ($_SERVER['REQUEST_URI']){
case "/":
echo "<h1>Home Page</h1>";
echo "<p>I like to code.</p>";
break;
case "/bear/":
echo "<h1>Picture of a bear</h1>";
echo "<img src=\"https://wallpapertag.com/wallpaper/full/4/e/4/437139-grizzly-bear-backgrounds-2000x1333-retina.jpg\" alt=\"picture of a cute bear\" />";
default:
echo "ERROR";
exit;
}